home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_pow_single_sequencer_m.cog < prev    next >
Text File  |  1998-02-25  |  5KB  |  187 lines

  1. # Jedi Knight MOTHS Cog Script
  2. #
  3. # POW_SINGLE_SEQUENCER_m.COG
  4. #
  5. # POWERUP Script - Single Sequencer
  6. #
  7. # [YB, CYW, SRS]
  8. #
  9. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  10.  
  11.  
  12. symbols
  13.  
  14. template    explode=+medium_exp             local
  15.  
  16. thing       powerup                          local
  17. thing       player                           local
  18. thing       sender                           local
  19.  
  20. int         bin=8                            local
  21. sound       pickupsnd=thrmlpu2.wav           local
  22. sound       respawnsnd=Activate01.wav        local
  23. flex        amount                           local
  24.  
  25. int         autosel=-1                       local
  26. int         bin_contents=0                   local
  27. int         autopickup=0                     local
  28. int         damage                           local
  29.  
  30. message     created
  31. message     damaged
  32. message     touched
  33. message     taken
  34. message     respawn
  35. message     timer
  36.  
  37. end
  38.  
  39. # ========================================================================================
  40.  
  41. code
  42.  
  43. created:
  44.    SetThingUserData(GetSenderRef(), 30);     // set the initial user data (i.e. "health")
  45.    Return;
  46.  
  47. # ............................................................................................
  48.  
  49. touched:
  50.    if (GetWeaponBin(bin) == -1)
  51.       return;
  52.  
  53.    player = GetSourceRef();
  54.    if (GetThingType(player) == 10)  // Can only be taken by players.
  55.    {
  56.       amount = GetInv(player, GetWeaponBin(bin));
  57.  
  58.       if (IsMulti() || (amount < GetInvMax(player, GetWeaponBin(bin))))
  59.       {
  60.          TakeItem(GetSenderRef(), -1);
  61.          call taken;
  62.       }
  63.    }
  64.  
  65.    Return;
  66.  
  67. # ........................................................................................
  68.  
  69. damaged:
  70.    damage = GetParam (0);
  71.    sender = GetSenderRef();
  72.  
  73.    // only take damage 33% of the time
  74.    if(rand() < 0.33)
  75.       return;
  76.  
  77.    // If it's already dead, don't allow any more damage.
  78.    if (!GetThingUserData (sender))
  79.       return;
  80.  
  81.    // see if this will cause the explosion
  82.    if (GetThingUserData (sender) <= damage)
  83.    {
  84.       SetThingUserData(sender, 0);
  85.  
  86.       // timer for base explosion
  87.       SetTimerEx ((Rand () * 0.5), sender, 1, 0);
  88.    }
  89.    else
  90.    {
  91.       SetThingUserData(sender, GetThingUserData (sender) - damage);
  92.    }
  93.  
  94.    ReturnEx (0);
  95.    return;
  96.  
  97. # ........................................................................................
  98.  
  99. taken:
  100.    if (GetWeaponBin(bin) == -1)
  101.       return;
  102.  
  103.    powerup = GetSenderRef();
  104.  
  105. // // If the object has been destroyed, don't award it to the player.
  106. //   if (!GetThingUserData (powerup))
  107. //    return;
  108.  
  109.    player = GetSourceRef();
  110.  
  111.    // Print("Sequencer Charge");
  112.    jkPrintUNIString(player, 206);
  113.  
  114.    // Do effects.
  115.    PlaySoundLocal(pickupsnd, 1, 0, 0);
  116.    AddDynamicTint(player, 0.0, 0.0, 0.2);
  117.  
  118.    // store the old bin contents
  119.    bin_contents = GetInv(player, GetWeaponBin(bin));
  120.  
  121.    // Increment powerup amount.
  122.    ChangeInv(player, GetWeaponBin(bin), 1.0);
  123.  
  124.    // For both uses.
  125.    if (!GetInv(player, GetWeaponBin(bin+10)))
  126.       SetInv(player, GetWeaponBin(bin+10), 1.0);
  127.  
  128.    // Check for Auto Pickup
  129.    autopickup = GetAutoPickup();
  130.    if((autopickup & 1) && !(autopickup & 2)) // DANGEROUS
  131.    {
  132.       if(!bin_contents)
  133.       {
  134.          if(!((autopickup & 4) && (GetWeaponPriority(player, GetWeaponBin(GetCurWeapon(player)), 0) >= GetWeaponPriority(player, bin, 0))))
  135.          {
  136.             if(!((autopickup & 8) && (GetWeaponBin(GetCurWeapon(player)) == jkGetMultiParam(1))))
  137.             {
  138.                   // Don't switch weapons if we are in manual mode already!
  139.                if (GetCurWeapon(player) != (bin + 10))
  140.                   SelectWeapon(player, bin);
  141.                Return;
  142.             }
  143.          }
  144.       }
  145.    }
  146.  
  147.    // Check for Auto Reload
  148.    if(GetAutoReload() & 1)
  149.    {
  150.       if(!bin_contents)
  151.       {
  152.          if(!((GetAutoReload() & 2) && (GetWeaponBin(GetCurWeapon(player)) == jkGetMultiParam(1))))
  153.          {
  154.             // Try to autoselect and see if the best weapon is the sequencer
  155.             autosel = AutoSelectWeapon(player, 2);
  156.  
  157.             if((autosel % 10) == 8)
  158.                   // Don't switch weapons if we are in manual mode already!
  159.                if (GetCurWeapon(player) != (bin + 10))
  160.                   SelectWeapon(player, autosel);
  161.          }
  162.       }
  163.    }
  164.  
  165.    return;
  166.  
  167. # ........................................................................................
  168.  
  169. respawn:
  170.    SetThingUserData(GetSenderRef(), 30);     // set the initial user data (i.e. "health")
  171.    PlaySoundThingLocal(respawnsnd, GetSenderRef(), 0.6, 5.0, 10.0, 0);
  172.  
  173.    return;
  174.  
  175. # ........................................................................................
  176.  
  177. timer:
  178.    sender = GetSenderId ();
  179.  
  180.    powerup = CreateThingNR(explode, sender);
  181.  
  182.    // Since the user data is 0, the player won't actually be awarded this powerup.
  183.    TakeItem(sender, -1);
  184.    return;
  185.  
  186. end
  187.